<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            子类：sub
            父类：sup
        */
        function extend(sub, sup) {
            sub.prototype = Object.create(sup.prototype);
            // constructor属性禁止遍历
            Object.defineProperty(sub.prototype, 'constructor', {
                value: sub,
                enumerable: false
            })
        }
        
        function User(name, age) {
            this.name = name;
            this.age = age;
        }
        User.prototype.show = function () {
            console.log(this.name, this.age);
        }
        function Admin(...args) {
            User.apply(this, args);
        }
        extend(Admin, User);
        let admin = new Admin('李思', 12)
        admin.show();
    </script>
</body>

</html>